<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="bean.*,java.util.LinkedList" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>超级管理员登录</title>
	<link rel="stylesheet" type="text/css" href="css/mystyle.css">
	<script type="text/javascript">
		var college = "";
		var className = "";
		var data = [];
		
		function andata(){
			var s = document.getElementById('hid').value;
			data = s.split("\u0001");
		}
		
		function selectCollege(obj){
			className = "";
			college = obj.options[obj.selectedIndex].value;
			var classes = data[obj.selectedIndex-1].split("\u0002");
			
	        var ccc = document.getElementById("ccc");
	        for (var i = ccc.length - 1; i > 0; i--) ccc.remove(i);
	        
	        for (var i = 0; i < classes.length-1; i++){
	        	var option = new Option(classes[i],classes[i]);
	        	ccc.options.add(option);
	        }
		}
		
		function selectClass(obj){
			className = obj.options[obj.selectedIndex].value;
		}
	</script>
</head>
<body onload="andata()">

	<div>
	<center><h1>登录</h1></center>
		<form action="ClassLogin.do" method="post">
			 <select name="college" class="item" onchange="selectCollege(this)"> 
			 	<option value="">请选择您学院</option>
			 	<%
			 		LinkedList<College> college = (LinkedList<College>) request.getAttribute("college");
			 		String classes = "";
			 		for(College c:college){
			 			LinkedList<bean.Class> cc = c.getClasses();
			 			for(bean.Class ccc:cc) classes +=ccc.getName()+"\u0002";
			 			classes+="\u0001";
			 	%>
    			<option value="<%=c.getName() %>"> <%=c.getName()%> </option> 
    			<%} %>
    		</select><br>
    		<select name="className" id="ccc" class="item" onchange="selectClass(this)">
    			<option value="">请选择班级</option> 
    		</select> <br>
    		<input type="hidden" id="hid" value="<%=classes %>">
			<input type="password" name="passwd" onfocus="this.value=''" value="请输入管理员口令" class="item text"><br>
			<input type="submit" name="" value="登入" class="item sub">
		</form>
	</div>
</body>
</html>